/** @jsxImportSource @emotion/react */
import * as React from "react";
import {Text, useTheme,} from "customize-easy-ui-component";
import {RepLink, ReportViewProps,} from "../../common/base";
import {末尾链接, 落款单位地址,} from "../../common/rarelyVary";
import {检验结论报告, } from "./viewRes";
import {useSubRepMain} from "../../hook/useSubRepMain";
import {useRepMenuDirItems} from "../../hook/useMainRepUrlOr";
import {宏观检验报告} from "./viewMacr";
import {资料审查报告} from "./viewReview";
import {首页设备概况VsWDj} from "./rarelyVary";
import {VsProjects默认} from "./editor";
import {useItemsMapPressure} from "../../common/pressure";
import {安全附件检验} from "./viewSAcces";
import {注意事项MVS, 目录页VS} from "../../movable/rarelyVary";
import {ReportFirstPageHeadNmaNmbm, } from "../../contain/rarelyVary";
import {分项表附页Vs} from "../viewProj";
import {附加检验报告} from "../../movable/RqThorough/viewAddon";

//原版多出的”附页.pdf“没纳入 ；  "强度校核报告.pdf"也自带的。
export const ReportView: React.FunctionComponent<ReportViewProps> = ({
    repId,   source: orc,  verId,rep,
}) => {
    const theme= useTheme();
    const [mapFxian]=useItemsMapPressure({ projects:orc.Projects });
    const [rootMenu]=useRepMenuDirItems(VsProjects默认, orc.Projects, `/reportView/${rep?.modeltype}/ver/${verId}/${repId}`);
    const [renderThickmVs]= useSubRepMain("cm/thickmVs", {nestMd:'THICKM_VS',orc, repId:repId!, rep, NestMbVer:1});
    const [renderPressure]= useSubRepMain("cm/pressure", {nestMd:'PRSRE_TS',orc, repId:repId!, rep, NestMbVer:1});
    const [renderGasproof ]= useSubRepMain("cm/gasproof", {nestMd:'GASPR_TS',orc, repId:repId!, rep, NestMbVer:1});
    //? 强度校核报告  是通用的吗？
    const [renderSpectrVs]= useSubRepMain("cm/spectrVs", {nestMd:'SPECTR_VS', orc, repId:repId!, rep, NestMbVer:1});
    const [renderRadioTs ]= useSubRepMain("cm/radio", {nestMd:'RADIO_TS',orc, repId:repId!, rep, NestMbVer:1});
    const [renderUtrSonic]= useSubRepMain("cm/sonic", {nestMd:'SONIC_TS',orc, repId:repId!, rep, NestMbVer:1});
    const [renderTofd]= useSubRepMain("cm/tofd", {nestMd:'TOFD_TS', orc, repId:repId!, rep, NestMbVer:1});
    const [magnetic ]= useSubRepMain("cm/magnetic", {nestMd:'MAGNT_TS',orc, repId:repId!, rep, NestMbVer:1});
    const [permeation ]= useSubRepMain("cm/permeation", {nestMd:'PERME_TS',orc, repId:repId!, rep, NestMbVer:1});
    const [hardness ]= useSubRepMain("cm/hardness", {nestMd:'HARD_TS',orc, repId:repId!, rep, NestMbVer:1});

    return (
    <React.Fragment>
        {rootMenu}
        <div css={{"@media not print": {marginTop: '1rem', marginBottom: '1rem'}}}>
          <div css={{
              display: 'flex',
              flexDirection: 'column',
              justifyContent: 'space-between',
              "@media print": {height:'100vh', pageBreakInside: 'avoid',}
          }}>
                {ReportFirstPageHeadNmaNmbm({theme, rep, mbbm: 'FJB/TM-1007-1-0-2022'})}
                <div>
                    <Text variant="h3" css={{
                        textAlign: 'center',
                        "@media (min-width:690px),print and (min-width:538px)": {
                            fontSize: theme.fontSizes[6],
                    }} }>
                     压力容器定期委托检查
                    </Text>
                    <br css={{"@media not print": {display: 'none'}}}/>
                    <Text variant="h5" css={{
                        textAlign: 'center',
                    }}> （ FJB/RC-1020-0-2022 ）
                    </Text>
                </div>
                <div>
                    {首页设备概况VsWDj({theme, orc, rep})}
                </div>
                <div css={{textAlign: 'center', "@media print": {pageBreakInside: 'avoid'}}}>
                    {落款单位地址}
                </div>
           </div>

            {注意事项MVS({
                rep,
                comply: '为依据《固定式压力容器安全技术监察规程》（TSG21-2016）制定，适用于压力容器定期检验报告的结论报告，检验结论仅代表该设备在检验时的安全状况'
            })}
            {目录页VS({theme, orc, rep, suffix: true})}
            {检验结论报告({theme, orc, rep})}

            { orc?.无分项页? <RepLink rep={rep} tag={'ProjectListGen'}>
                    <Text variant="h4" css={{"@media print": {display: 'none'}}}>当前未添加压力容器定期检验报告附页，若需要去生成这一页</Text>
                </RepLink>
                :
                分项表附页Vs({theme, orc, rep})
            }

            {资料审查报告({theme, orc, rep})}
            {宏观检验报告({theme, orc, rep})}

            {mapFxian.get('壁厚测定')?.do &&  renderThickmVs }
            {mapFxian.get('耐压强度校核')?.do && <h2>模板还未做的分项</h2>}
            {mapFxian.get('射线检测')?.do &&  renderRadioTs }
            {mapFxian.get('超声检测')?.do &&  renderUtrSonic }
            {mapFxian.get('衍射时差法（TOFD）超声检测')?.do &&  renderTofd }
            {mapFxian.get('磁粉检测')?.do &&  magnetic }
            {mapFxian.get('渗透检测')?.do &&  permeation }

            {mapFxian.get('声发射检测')?.do && <h2>模板还未做的分项</h2>}
            {mapFxian.get('光谱分析')?.do &&  renderSpectrVs }
            {mapFxian.get('硬度检测')?.do &&  hardness }
            {mapFxian.get('金相分析')?.do && <h2>模板还未做的分项</h2>}
            {mapFxian.get('安全附件检验')?.do &&
                安全附件检验({theme, orc, rep})
            }
            {mapFxian.get('耐压试验')?.do && renderPressure }
            {mapFxian.get('气密性试验报告')?.do && renderGasproof }
            {mapFxian.get('氨检漏试验')?.do && <h2>模板还未做的分项</h2>}
            {mapFxian.get('氦、卤素检漏试验')?.do && <h2>模板还未做的分项</h2>}

            {mapFxian.get('附加检验')?.do &&
                附加检验报告({theme, orc, rep,jyjg:'检测结果'})
            }
        </div>
        {末尾链接({template: rep?.modeltype, verId, repId: repId || ''})}
    </React.Fragment>
  );
}
